from rest_framework import serializers

from apps.goods.models import SPUSpecification, SPU


class SPUSpecificationSerialzier(serializers.ModelSerializer):
    """
    商品规格序列化器
    """
    spu = serializers.StringRelatedField(read_only=True)
    spu_id = serializers.IntegerField()

    class Meta:

        model = SPUSpecification
        fields = ('id','name','spu','spu_id')

class SPUSerialzier(serializers.ModelSerializer):

    class Meta:

        model = SPU
        fields = ('id','name')